import java.util.*;

public  class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        Stack<Character> stack=new Stack<>();
        String str=scanner.nextLine();
        for(int i=0;i<str.length();i++){
            char c=str.charAt(i);
            if(c=='('||c=='{'||c=='{'){
                stack.push(c);
            }
            else {
                if(stack.empty()){
                    System.out.println("false");
                    return;
                }
                char tmp=stack.peek();
                if(tmp=='('&&c==')' ||tmp=='{'&&c=='}' ||tmp=='['&&c==']' ){
                    stack.pop();
                }
                else {
                    System.out.println(false);
                    return;
                }
            }
        }
        if(stack.empty())
        System.out.println("true");
    }
    public static void main4(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        String[] strings=new String[n];
        scanner.nextLine();
        Map<String ,ArrayList<String>> hash=new HashMap<>();
        for(int i=0;i<n;i++){
            strings[i]=scanner.nextLine();
        }
        for(String x: strings){
            char[] c=x.toCharArray();
            Arrays.sort(c);
            String key=new String(c);
            if(!hash.containsKey(key)){
                hash.put(key,new ArrayList<>());
            }
            hash.get(key).add(x);
        }
       List<List<String>> arrayLists=new ArrayList(hash.values());
        System.out.println(Arrays.toString(arrayLists.toArray()));
    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String string1=scanner.nextLine();
        String string2=scanner.nextLine();
        int[] ints=new int[26];
        for(int i=0;i<string1.length();i++){
            ints[string1.charAt(i)-'a']+=1;
        }
        for(int i=0;i<string2.length();i++){
            if(ints[string2.charAt(i)-'a']==0){
                System.out.println("false");
                return;
            }
            ints[string1.charAt(i)-'a']-=1;
        }
        System.out.println("true");

    }
    //判断重排
    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String string1=scanner.nextLine();
        String string2=scanner.nextLine();
        Set<Character> has=new HashSet<>();
        for(int i=0;i<string1.length();i++){
            has.add(string1.charAt(i));
        }
        for(int i=0;i<string2.length();i++){
            if(!has.contains(string2.charAt(i))){
                System.out.println("false");
                return ;
            }
        }
        System.out.println("true");

    }
    //重复元素
    public static void main1(String[] args) {
        Map<Integer,Integer> hash=new HashMap<>();
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int k=scanner.nextInt();
        int[] ints=new int[n];
        for(int i=0;i<n;i++){
            ints[i]=scanner.nextInt();
        }
        for(int i=0;i<n;i++){
            if(hash.containsKey(ints[i])&&(i- hash.get(ints[i]))<=k){
                System.out.println("true");
                return;
            }
            hash.put(ints[i],i );
        }
        System.out.println("false");
    }

}
